;(function(){
	'use strict';
	angular.module('controllers.oldOMDisplay.operationDevelop')
		.controller('sysOnlineChangeController', sysOnlineChangeController);
	function sysOnlineChangeController($scope,sysOnlineChangeService,odOperationDevelop,CoreService){
		//控制查询条件拉上拉下   1为拉下  0 为拉上
		$scope.shoumun = {
			num: 1
		};
		$scope.sendData = sysOnlineChangeService.getPageBind();
		$scope.riskLevs = sysOnlineChangeService.getRiskData();
		//控制等待样式   false 为隐藏   true 为显示
		$scope._loading.show = false;
		var myEcharts = echarts.init(document.getElementById('doc'));
		$scope.search = function(){
			if ($scope.shoumun.num === 1) {
				$scope.shoumun.num = 1;
				return;
			}
			// return;
			$scope._loading.show = true;
			$scope.params = {};
			$scope.title = '';
			var startTime = CoreService.dateFormat($scope.sendData.startTime,'yyyy-MM');
			var endTime = CoreService.dateFormat($scope.sendData.endTime,'yyyy-MM');
			if(startTime === endTime){
				$scope.title = startTime.replace(/-/g,'')+'变更风险级别统计';
			}else {
				$scope.title = startTime.replace(/-/g,'')+'_'+endTime.replace(/-/g,'')+'变更风险级别统计';
			}
			$scope.params.startTime = startTime;
			$scope.params.endTime = endTime;
			sysOnlineChangeService.queryRiskLev($scope.params,function(res){
				if (res.state === '10000') {
					var myOption = odOperationDevelop.getEchartsData(res.data,$scope.title,'time','riskName','riskNum','bar');
					myEcharts.setOption(myOption);
					$scope._loading.show = false;
					$scope.flag = 'view';
					var ecConfig = echarts.config;
					myEcharts.on(ecConfig.EVENT.CLICK,downDet);
				}else if(res.data.length ===0) {
					$scope.shoumun.num = 1;
					CoreService.dialog('查询无数据');
				}else {
					CoreService.dialog('查询错误');
				}
			});
		};
		$scope.back = function(){
			$scope.flag = 'view';
		};
		function downDet(){
			var params = {};
			sysOnlineChangeService.queryDet($scope.params,function(res){
				if (res.state === '10000') {
					$scope.flag = 'table';
					$scope.items = res.data;
				}else if(res.data.length ===0) {
					$scope.shoumun.num = 1;
					CoreService.dialog('查询无数据');
				}else {
					CoreService.dialog('查询错误');
				}
			});
		}
	}
	sysOnlineChangeController.$inject = ['$scope','sysOnlineChangeService','odOperationDevelop','CoreService'];
})();